package com.itrencai.d1_static.demoshuzu;

public class Tool {
    //工具类构造器私有化
    private Tool(){

    }
    //返回数组内容
/*    public static String printArray(int[] arr){
        System.out.println("[");
        for (int i = 0; i < arr.length; i++) {
            System.out.println(i== arr.length-1?arr[i]:arr[i]+",");
        }
        System.out.println("]");
    }*/
    //返回数组内容
    public static String toSring(int[] arr){
        if(arr!=null){
            String result="[";
            for (int i = 0; i < arr.length; i++) {
                result+=(i== arr.length-1?arr[i]:arr[i]+",");
            }
            result+="]";
            return result;
        }else{
            return null;
        }

    }





    //统计平均值,去掉最高分最低分求平均分
    public static double getAverage(int[] arr){
        //总和 最大值 最小值
        int max=arr[0];
        int main=arr[0];
        int sum=0;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i]>max){
                max=arr[i];
            }
            if(arr[i]<main){
                main=arr[i];
            }
            sum+=arr[i];
        }
        return (sum-max-main)*1.0/(arr.length-2);
    }
}
